#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 25;

int n, m;
int a[5][N], d;
int f(int a[]) {
  int cnt = 0;
  rep(i, 1, n - 1) if (a[i] + 1 != a[i + 1]) cnt++;
  return (cnt + 2) / 3;
}
bool check(int a[]) {
  rep(i, 1, n) if (a[i] != i) return false;
  return true;
}
void copy(int a[], int b[], int l, int r, int s) {
  int i = 1;
  rep(j, 1, s - 1) a[i++] = b[j];
  rep(j, l, r) a[i++] = b[j];
  rep(j, s, l - 1) a[i++] = b[j];
  rep(j, r + 1, n) a[i++] = b[j];
}
bool dfs(int s) {
  if (s + f(a[s]) > d) return false;
  if (s == d) return check(a[s]);
  rep(i, 1, n) {
    rep(j, i + 1, n) rep(k, j, n) {
      copy(a[s + 1], a[s], j, k, i);
      if (dfs(s + 1)) return true;
    }
  }
  return false;
}
void solve() {
  cin >> n;
  rep(i, 1, n) cin >> a[0][i];
  d = 0;
  while (d < 5 && !dfs(0)) d++;
  if (d < 5)
    cout << d << endl;
  else
    cout << "5 or more" << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}